﻿namespace SnakeShop.Auth.Policys
{
    /// <summary>
    /// API 返回 结构
    /// </summary>
    public class ApiResponse
    {
        public int Status { get; set; } = 404;

        public object value { set; get; } = "Not Found";

        public ApiResponse(StatusCode apiCode, object msg = null)
        {
            switch (apiCode)
            {
                case StatusCode.CODE_401:
                {
                    Status = 401;
                    value = "没有权限访问此资源";

                }break;
                case StatusCode.CODE_403:
                {
                    Status = 403;
                    value = "禁止访问此资源";
                }break;
                case StatusCode.CODE_404:
                {
                    Status = 404;
                    value = "未找到此资源";

                }break;
                case StatusCode.CODE_500:
                {
                    Status = 500;
                    value= msg??"服务器错误";
                }break;

            }
        }


    }

    public enum StatusCode
    {
        /// <summary>
        /// 未授权
        /// </summary>
        CODE_401,
        /// <summary>
        /// 禁止访问
        /// </summary>
        CODE_403,
        /// <summary>
        /// 未找到
        /// </summary>
        CODE_404,
        /// <summary>
        /// 服务器错误
        /// </summary>
        CODE_500
    }

}
